package com.abel.domain.types;

import java.util.ArrayList;
import java.util.List;

public enum MaritalStatus {

	SINGLE("single", "S"), 
    MARRIED("married", "M"), 
    SEPARATED("separated", "U"),
    DIVORCED("divorced","D"); 
	
	
    private String maritalStatusDesc;
    
    private String maritalStatusCode;
    
    private MaritalStatus (String maritalStatusDesc, String maritalStatusCode) {
        this.maritalStatusDesc = maritalStatusDesc;
        this.maritalStatusCode = maritalStatusCode;
        
    }


    
    /**
	 * @return the maritalStatusDesc
	 */
	public String getMaritalStatusDesc() {
		return maritalStatusDesc;
	}



	/**
	 * @return the maritalStatusCode
	 */
	public String getMaritalStatusCode() {
		return maritalStatusCode;
	}



	public static String getMaritalStatusCode(String maritalStatusDesc) {
        
		if (maritalStatusDesc != null) {
            
			for (MaritalStatus m : MaritalStatus.values()) {
                
				if (maritalStatusDesc.equalsIgnoreCase(m.getMaritalStatusDesc())) {
                    
					return m.getMaritalStatusCode();
                
				}
            }
        }
        return null;
    }

	public static String getMaritalStatusDesc(String maritalStatusCode) {
        
		if (maritalStatusCode != null) {
            
			for (MaritalStatus m : MaritalStatus.values()) {
                
				if (maritalStatusCode.equalsIgnoreCase(m.getMaritalStatusCode())) {
                    
					return m.getMaritalStatusDesc();
                
				}
            }
        }
        return null;
    }
	
	public static List<String> getMaritalStatusDescAsList() {
		
		List<String> list = new ArrayList<String>();
		
		for (MaritalStatus m : MaritalStatus.values()) {
			
			list.add(m.maritalStatusDesc);
        
		}
		return list;
	}
}
